﻿using System;
using System.Data;
using System.Windows.Forms;

namespace EA_therapy
{
    public partial class Disease : Form
    {
        Panel father;
        public Disease(Panel _father)
        {
            InitializeComponent();
            father = _father;
            Global.disID = Global.ID.Substring(14, 4) + DateTime.Now.ToString("hhmm");
            Global.disID = Global.disID.TrimStart('0');
            label8.Text = "本次治疗号为：" + Global.disID;
            DataTable temp1 = EADB.GetBM();
            DataTable temp2 = EADB.GetZX();
            for (int i = 0; i < temp1.Rows.Count; i++)
                nod.Items.Add(temp1.Rows[i][0]);
            for (int i = 0; i < temp2.Rows.Count; i++)
                tod.Items.Add(temp2.Rows[i][0]);

        }

        private void reset_Click(object sender, EventArgs e)
        {
            this.xw11.Text = this.xw21.Text = this.xw31.Text = this.xw41.Text = nod.Text = tod.Text = sick.Text = "";
        }

        private void start_Click(object sender, EventArgs e)
        {
            string info = Global.disID + "','";
            info += Global.ID + "','";
            info += this.nod.Text + "','";
            info += this.tod.Text + "','";
            info += this.sick.Text + "','";
            info += this.xw11.Text + "-" + this.xw12.Text + "','";
            info += this.xw21.Text + "-" + this.xw22.Text + "','";
            info += this.xw31.Text + "-" + this.xw32.Text + "','";
            info += this.xw41.Text + "-" + this.xw42.Text;
            EADB.isBMExist(nod.Text);
            EADB.isZXExist(tod.Text);
            EADB.AddCute(info);
            DZ newform = new DZ(father);
            newform.FormBorderStyle = FormBorderStyle.None;
            newform.TopLevel = false;
            newform.ControlBox = false;
            newform.Dock = DockStyle.Fill;
            this.father.Controls.Add(newform);
            newform.Show();
            this.Close();
        }

        private void back_Click(object sender, EventArgs e)
        {
            this.Close();
            Patient newform = new Patient(father);
            newform.FormBorderStyle = FormBorderStyle.None;
            newform.TopLevel = false;
            newform.ControlBox = false;
            newform.Dock = DockStyle.Fill;
            this.father.Controls.Add(newform);
            newform.Show();
            this.Close();
        }

        private void 删除当前证明ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                EADB.DelBM(nod.Text);
            }
            catch
            {
                MessageBox.Show("删除失败！");
            }
            MessageBox.Show("删除成功！");
        }

        private void 删除当前整形ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                EADB.DelZX(tod.Text);
            }
            catch
            {
                MessageBox.Show("删除失败！");
            }
            MessageBox.Show("删除成功！");
        }

        private void Disease_Load(object sender, EventArgs e)
        {

        }
    }
}
